import { createRouter, createWebHashHistory } from 'vue-router'
import store from '../store/index.js'

import Home from '../views/Home.vue'
import AdminHome from '../views/AdminHome.vue'
import AdminArrangement from '../views/AdminArrangement.vue'
import AdminAuditorium from '../views/AdminAuditorium.vue'
import AdminComment from '../views/AdminComment.vue'
import AdminMovies from '../views/AdminMovies.vue'
import AdminOrders from '../views/AdminOrders.vue'
import AdminStatistics from '../views/AdminStatistics.vue'
import Login from '../views/Login.vue'
import Default from '../views/Default.vue'
import movieList from '../views/movieList.vue'
import movieInfo from '../views/movieInfo.vue'
import Buy from '../views/Buy.vue'
import myOrder from '../views/myOrder.vue'
import moviePush from '../views/moviePush.vue'
import Register from '../views/Register.vue'
import userInfo from '../views/userInfo.vue'
import updateUser from '../views/updateUser.vue'
import DefaultMobile from '../views/clientMobile/DefaultMobile.vue'
import LoginMobile from '../views/clientMobile/LoginMobile.vue'
import movieListMobile from '../views/clientMobile/movieListMobile.vue'
import movieInfoMobile from '../views/clientMobile/movieInfoMobile.vue'
import BuyPlanMobile from '../views/clientMobile/BuyPlanMobile.vue'
import myOrderMobile from '../views/clientMobile/myOrderMobile.vue'
import moviePushMobile from '../views/clientMobile/moviePushMobile.vue'
import userInfoMobile from '../views/clientMobile/userInfoMobile.vue'
import userStaMobile from '../views/clientMobile/userStaMobile.vue'
import RegisterMobile from '../views/clientMobile/RegisterMobile.vue'
import updateUserMobile from '../views/clientMobile/updateUserMobile.vue'
import userSta from '../views/userSta.vue'
import wxLogin from '../views/wxLogin.vue'
import wxLoginMobile from '../views/clientMobile/wxLoginMobile.vue'

const routes = [
  {
    path: '/PhoneAdminHome',
    name: 'PhoneAdminHome',
    component: () => import('../views/AdminPhone/PhoneAdminHome.vue'),
    children: [
      {
        path: '/PhoneAdminUser',
        name: 'PhoneAdminUser',
        component: () => {
          if (store.state.admin === true) {
            return import('../views/AdminPhone/PhoneAdminUser.vue')
          }
        }
      },
      {
        path: '/PhoneAdminArrangement',
        name: 'PhoneAdminArrangement',
        component: () => import('../views/AdminPhone/PhoneAdminArrangement.vue')
      },
      {
        path: '/PhoneAdminAuditorium',
        name: 'PhoneAdminAuditorium',
        component: () => import('../views/AdminPhone/PhoneAdminAuditorium.vue')
      },
      {
        path: '/PhoneAdminComment',
        name: 'PhoneAdminComment',
        component: () => import('../views/AdminPhone/PhoneAdminComment.vue')
      },
      {
        path: '/PhoneAdminMovies',
        name: 'PhoneAdminMovies',
        component: () => import('../views/AdminPhone/PhoneAdminMovies.vue')
      },
      {
        path: '/PhoneAdminOrders',
        name: 'PhoneAdminOrders',
        component: () => import('../views/AdminPhone/PhoneAdminOrders.vue')
      },
      {
        path: '/PhoneAdminStatistics',
        name: 'PhoneAdminStatistics',
        component: () => import('../views/AdminPhone/PhoneAdminStatistics.vue')
      },
      {
        path: '/PhoneAdminSuggest',
        name: 'PhoneAdminSuggest',
        component: () => {
          if (store.state.admin === true) {
            return import('../views/AdminPhone/PhoneAdminSuggest.vue')
          }
        }
      }
    ]
  },
  {
    path: '/AdminHome',
    name: 'AdminHome',
    component: AdminHome,
    children: [
      {
        path: '/AdminUser',
        name: 'AdminUser',
        component: () => {
          if (store.state.admin === true) {
            return import('../views/AdminUser')
          }
        }
      },
      {
        path: '/AdminArrangement',
        name: 'AdminArrangement',
        component: AdminArrangement
      },
      {
        path: '/AdminAuditorium',
        name: 'AdminAuditorium',
        component: AdminAuditorium
      },
      {
        path: '/AdminComment',
        name: 'AdminComment',
        component: AdminComment
      },
      {
        path: '/AdminMovies',
        name: 'AdminMovies',
        component: AdminMovies
      },
      {
        path: '/AdminOrders',
        name: 'AdminOrders',
        component: AdminOrders
      },
      {
        path: '/AdminStatistics',
        name: 'AdminStatistics',
        component: AdminStatistics
      },
      {
        path: '/AdminSuggest',
        name: 'AdminSuggest',
        component: () => {
          if (store.state.admin === true) {
            return import('../views/AdminSuggest.vue')
          }
        }
      }
    ]
  },
  {
    path: '/Home',
    name: 'Home',
    component: Home
  },
  {
    path: '/Login',
    name: 'Login',
    component: Login
  },
  {
    path: '/',
    name: 'Default',
    component: Default
  },
  {
    path: '/movieList',
    name: 'movieList',
    component: movieList
  },
  {
    path: '/movieInfo',
    name: 'movieInfo',
    component: movieInfo
  },
  {
    path: '/Buy',
    name: 'Buy',
    component: Buy
  },
  {
    path: '/myOrder',
    name: 'myOrder',
    component: myOrder
  },
  {
    path: '/moviePush',
    name: 'moviePush',
    component: moviePush
  },
  {
    path: '/Register',
    name: 'Register',
    component: Register
  },
  {
    path: '/userInfo',
    name: 'userInfo',
    component: userInfo
  },
  {
    path: '/updateUser',
    name: 'updateUser',
    component: updateUser
  },
  {
    path: '/userSta',
    name: 'userSta',
    component: userSta
  },
  {
    path: '/DefaultMobile',
    name: 'DefaultMobile',
    component: DefaultMobile
  },
  {
    path: '/LoginMobile',
    name: 'LoginMobile',
    component: LoginMobile
  },
  {
    path: '/movieListMobile',
    name: 'movieListMobile',
    component: movieListMobile
  },
  {
    path: '/movieInfoMobile',
    name: 'movieInfoMobile',
    component: movieInfoMobile
  },
  {
    path: '/BuyPlanMobile',
    name: 'BuyPlanMobile',
    component: BuyPlanMobile
  },
  {
    path: '/myOrderMobile',
    name: 'myOrderMobile',
    component: myOrderMobile
  },
  {
    path: '/moviePushMobile',
    name: 'moviePushMobile',
    component: moviePushMobile
  },
  {
    path: '/userInfoMobile',
    name: 'userInfoMobile',
    component: userInfoMobile
  },
  {
    path: '/userStaMobile',
    name: 'userStaMobile',
    component: userStaMobile
  },
  {
    path: '/RegisterMobile',
    name: 'RegisterMobile',
    component: RegisterMobile
  },
  {
    path: '/updateUserMobile',
    name: 'updateUserMobile',
    component: updateUserMobile
  },
  {
    path: '/wxLogin',
    name: 'wxLogin',
    component: wxLogin
  },
  {
    path: '/wxLoginMobile',
    name: 'wxLoginMobile',
    component: wxLoginMobile
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
